package hash;


import java.util.HashMap;
import java.util.LinkedList;
import java.util.TreeMap;
import java.util.UUID;

public class Demo {
    public static void main(String[] args) {
        String[] s = new String[100000];
        LinkedList<String> lk = new LinkedList();
        TreeMap<Integer,String> tm = new TreeMap();
        HashMap<Integer,String> hm = new HashMap();
        for (int i = 0; i <s.length ; i++) {
            String uuid = UUID.randomUUID().toString();
            s[i] = uuid;
            lk.add(uuid);
            tm.put(i,uuid);
            hm.put(i,uuid);
        }
        //查询中部数据
        int index = s.length/2;
        long t0 = System.nanoTime();

        String s1 = s[index];
        long t1 = System.nanoTime();

        String s2 = lk.get(index);
        long t2 = System.nanoTime();

        String s3 = tm.get(index);
        long t3 = System.nanoTime();

        String s4 = hm.get(index);
        long t4 = System.nanoTime();

        System.out.println("arr:"+(t1-t0));
        System.out.println("LinkedList:"+(t2-t1));
        System.out.println("Tree:"+(t3-t2));
        System.out.println("HashMap:"+(t4-t3));

        System.out.println("arr:"+s1);
        System.out.println("LinkedList:"+s2);
        System.out.println("Tree:"+s3);
        System.out.println("HashMap:"+s4);
    }
}
